#!/bin/bash
# API测试脚本（Linux/Mac）

echo "========================================"
echo "API接口测试"
echo "========================================"
echo ""

# 检查后端服务是否运行
echo "检查后端服务..."
if ! curl -s http://localhost:8000/api/ > /dev/null 2>&1; then
    echo "错误: 后端服务未运行"
    echo "请先启动: python manage.py runserver"
    exit 1
fi
echo "后端服务运行正常"
echo ""

# 测试公开API
echo "[1/4] 测试公开API..."
curl -s http://localhost:8000/api/attractions/?page_size=1 | python3 -m json.tool
echo ""
echo ""

# 测试推荐路线
echo "[2/4] 测试推荐路线API..."
curl -s http://localhost:8000/api/routes/history/recommended/?limit=3 | python3 -m json.tool
echo ""
echo ""

# 测试热门路线
echo "[3/4] 测试热门路线API..."
curl -s http://localhost:8000/api/routes/history/hot/?limit=3 | python3 -m json.tool
echo ""
echo ""

# 测试系统健康检查
echo "[4/4] 测试系统健康检查API..."
echo "提示: 需要管理员权限"
echo ""

echo "========================================"
echo "API测试完成"
echo "========================================"
echo ""
echo "提示: 如需测试需要认证的API，请先登录获取Token"
echo ""

